package com.spark.invoicings.utils;

public class Result<T> {

    private int code;
    private String msg;

    private T t;

    public Result(T t) {
        this.code = code;
        this.msg = msg;
        this.t = t;
    }

    public Result() {
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }
    public static Result success(){
        Result result = new Result<>();
        result.setCode(200);
        result.setMsg("success");
        return result;
    }
    public static<T> Result<T> success(int code,String msg,T data){
        Result<T> result = new Result<>(data);
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    public static<T> Result <T> error(int code,String msg,T data){
        Result<T> result = new Result<>(data);
        result.setMsg(msg);
        result.setCode(code);
        return result;
    }
    public static Result  error(int code,String msg){
        Result result = new Result<>();
        result.setMsg(msg);
        result.setCode(code);
        return result;
    }
}
